<?php
declare(strict_types=1);
namespace App\Controller\Api;

use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\RequestMapping;
use App\Controller\AbstractController;
use App\Service\CommonDataService\ServerConfigDataService;

/**
 * @Controller(prefix="/ServerConfig")
 * 服务配置查询中心
 */
class ServerConfigController extends AbstractController
{
    /**
     * 服务配置查询
     * @RequestMapping(path="queryServiceConfig", methods="POST")
     * @return string[]
     */
    public function queryServiceConfig(RequestInterface $request,ServerConfigDataService $ServerConfigDataService) 
    {
        return $ServerConfigDataService->queryServiceConfig(
            (string)$request->input('service_code'),
            (int)$request->input('service_type'),
            (string)$request->input('service_platform_value'),
            (bool)$request->input('is_single_field')
        );
    }
    /**
     * 获取三方配置信息列表
     * @RequestMapping(path="queryServiceConfigList", methods="POST")
     * @return string[]
     */
    public function queryServiceConfigList(RequestInterface $request,ServerConfigDataService $ServerConfigDataService)
    {
        return $ServerConfigDataService->queryServiceConfigList(
            (string)$request->input('serviceCode'),
            (int)$request->input('serviceType'),
            (int)$request->input('limit'),
            (int)$request->input('page')
            );
    }
    /**
     * 获取三方配置
     * @RequestMapping(path="queryServiceCodeList", methods="POST")
     * @return string[]
     */
    public function queryServiceCodeList(RequestInterface $request,ServerConfigDataService $ServerConfigDataService)
    {
        return $ServerConfigDataService->queryServiceCodeList(
            (int)$request->input('serviceType')
            );
    }
    
    /**
     * 新增三方业务配置
     * @RequestMapping(path="addServiceConfig", methods="POST")
     * @return string[]
     */
    public function addServiceConfig(RequestInterface $request,ServerConfigDataService $ServerConfigDataService)
    {
        return $ServerConfigDataService->addServiceConfig(
            (string)$request->input('serviceCode'),
            (int)$request->input('serviceType'),
            (string)$request->input('servicePlatformValue'),
            (string)$request->input('serviceThirdValue'),
            (string)$request->input('serviceName')
            );
    }

    /**
     * 修改三方业务配置
     * @RequestMapping(path="updateServiceConfig", methods="POST")
     * @return string[]
     */
    public function updateServiceConfig(RequestInterface $request,ServerConfigDataService $ServerConfigDataService)
    {
        return $ServerConfigDataService->updateServiceConfig(
            (int)$request->input('ID'),
            (string)$request->input('serviceCode'),
            (int)$request->input('serviceType'),
            (string)$request->input('servicePlatformValue'),
            (string)$request->input('serviceThirdValue'),
            (string)$request->input('serviceName')
            );
    }
}